package com.tansty.web.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * description:  <br>
 * date: 2021/8/24 13:16 <br>
 * author: ztz <br>
 * version: 1.0 <br>
 */
@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("insert 。。。。");
        this.strictInsertFill(metaObject, "createDate", LocalDateTime.class, LocalDateTime.now());
        this.strictUpdateFill(metaObject, "lastLogin", LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("update 。。。。");
        this.strictUpdateFill(metaObject, "lastLogin", LocalDateTime.class, LocalDateTime.now());
    }
}
